package com.nexfra.bbssys.common.utils;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.i18n.SessionLocaleResolver;

import com.nexfra.bbssys.common.Constants;
import com.nexfra.bbssys.common.domain.User;

public class SessionUtil {

	/**
	 * 세션에 설정된 로케일 언어를 리턴한다.
	 * @param request HttpServletRequest
	 * @return
	 */
	public static String getLang(HttpServletRequest request){
		HttpSession session = request.getSession();
		Locale locale = (Locale)session.getAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME);
		return locale.getLanguage();
	}
	
	/**
	 * 세션에 설정된 회사ID를 리턴한다.
	 * @param request HttpServletRequest
	 * @return
	 */
	public static String getComId(HttpServletRequest request){
		HttpSession session = request.getSession();
		User user = (User)session.getAttribute(Constants.USER_KEY);
		return user.getComId();
	}
}
